﻿//Lesson标记
var flag=0;
//1Agreement 2Lesson
function SelAOrL(val)
{
    if(val==1){
        $("selAgreement").className="first selATags";
        $("selLesson").className="";
        $("AgreementID").style.display="";
        $("LessonID").style.display="none";
    }
    else{
        
        $("selAgreement").className="first";
        $("selLesson").className="selATags";
        if(flag==0)
        {
           WebServices.User.Teach.GetLessonDesc(LID,onsuccLesson);
        }       
        $("AgreementID").style.display="none";
        $("LessonID").style.display=""; 
    }    
}
function onsuccLesson(result)
{
    if(result!=null&&result!="")
    {
        $("LessonID").innerHTML="<div class=''>"+LTile+"</div><br/>"+CTile+"<br/>"+result;
        flag=1;
    }
}

function AddMessage()
{
    var msg = $("tMessage").value.replace(/<script[^>]*>([\u0001-\uFFFF]*?)<\/script>/gi,"");
    if(msg=="")
    {
        return;
    }
    if(msg.length>1000)
    {
        msg=msg.substring(0,999);
    }
    WebServices.User.Teach.AddGetMessage(SID,msg,onsuccMessage);
}
function onsuccMessage(result)
{
    if(result!=null)
    {
        var domDiv =$get("MessagesID");
        if(domDiv!=null)
        {
            if($get("MessageItem")==null) return;
            var item= $get("MessageItem").innerHTML;
            var listBuilder = new Sys.StringBuilder();
            var msgCount = result[0].length;
            for (var index = 0; index < msgCount; index++) 
            {              
                var obj = result[0][index];                     
                var tmp = item.replace(/\$userFrom\$/gi,obj.userFrom).replace(/\$nickname\$/gi,obj.nickname).replace(/\$content\$/gi,obj.content);
                tmp = tmp.replace(/\$DiffDate\$/gi,GetFormatDate(gDateFormat,gStrDate,obj.DiffDate));
                listBuilder.append(tmp);
            }
            var sTemp = listBuilder.toString();
            domDiv.innerHTML = sTemp;
            $("tMessage").value="";
        }
    }
}
//老师feedback
function Feedback()
{
    if(__P_M==""){top.location = "/user/login.htm?IsShow=1&ReturnUrl="+top.location.href;return;}
    showProgressBar(false,true);
    $("$divIput$").style.display = "none";   
    
    var obj = {}
    $ShowMessageBox$(Title,body,obj,webFailure,600);
}
function webFailure()
{
    $EndMessageBox$();
}
function FB()
{
    desc=$("tareaFeedback").value.replace(/<script[^>]*>([\u0001-\uFFFF]*?)<\/script>/gi,"");
    if(desc=="")
    {
        return;
    }
    if(desc.length>1000)
    {
        desc=desc.substring(0,999);
    }
    $("tToSDesc").value=desc;
    var obj = $("Form1");    
    if(obj!=null)obj.submit();
    //WebServices.My.AddTToSDesc(Sid,desc);
    $EndMessageBox$();
}

//
var OPVal="";
function OP(val)
{
    OPVal=val;
    showProgressBar(false,true);
    $("$divIput$").style.display = "none";   
    
    var obj = {}
    var title="";
    var body="";
    if(val=='4'){title=op4Title;body=op4Body;}
    else if(val=="1"){title=op1Title;body=op1Body;}
    else if(val=="5"){title=op5Title;body=op5Body;}
    
    $ShowMessageBox$(title,body,obj,webFailure,400);
    
//    $("op").value=val;
//    var obj = $("Form1");    
//    if(obj!=null)obj.submit();
}
function executeOP()
{   
    $EndMessageBox$();
    $("op").value=OPVal;
    var obj = $("Form1");    
    if(obj!=null)obj.submit();
}